package com.api.sysmodule.reponse;

import java.io.Serializable;

import com.alibaba.fastjson.JSON;

/**
 * @ClassName: JsonResult
 * @Description:返回结果封装类
 * @author: liujp
 * 
 */
public class JsonResult implements Serializable {

	private static final long serialVersionUID = 7883489206566745212L;
	public static final String SUCCESS_CODE = "200";
	
	/**
	 * 300-登录失败，密码不正确
	 */
	public static final String PWD_INCORRECT = "300";
	/**
	 * 301-登录失败，用户不存在
	 */
	public static final String USER_NOT_EXIT = "301";
	/**
	 * 400-错误请求[服务器不理解请求的语法]
	 */
	public static final String BAD_REQUEST = "400";
	/**
	 * 401-未授权[对于登录后请求的网页，服务器可能返回此响应]
	 */
	public static final String UNAUTHORIZED = "401";
	/**
	 * 403-禁止[服务器拒绝请求]
	 */
	public static final String FORBIDDEN = "403";
	/**
	 * 404-未找到[服务器找不到请求的资源]
	 */
	public static final String NOT_FOUND = "404";
	/**
	 * 405-方法禁用[禁用请求中指定的方法]
	 */
	public static final String METHOD_ISABLE = "405";
	/**
	 * 406-不接受[无法使用请求的内容特性响应请求的网页]
	 */
	public static final String REQUEST_REJECT = "406";
	/**
	 * 408-请求超时[服务器等候请求时发生超时]
	 */
	public static final String REQUEST_TIMEOUT = "408";
	/**
	 * 　409-冲突[服务器在完成请求时发生冲突]
	 */
	public static final String REQUEST_CONFICT = "409";
	
	public static final String SUCCESS = "success";// 成功
	public static final String ERROR = "error";// 失败
	
	private String status;// 请求状态
	private String resultCode;// 状态码
	private String message;// 信息
	private Object data;// 数据
	private Object extradata;//附加数据
	
	private boolean allowchange;

	public JsonResult() {
		super();
	}

	/**
	 * @Title: JsonResult
	 * @Description: 失败信息返回
	 * @param: @param status
	 * @param: @param resultCode
	 * @param: @param message
	 * @throws
	 */
	public JsonResult(String status, String resultCode, String message) {
		super();
		this.status = status;
		this.resultCode = resultCode;
		this.message = message;
	}

	/**
	 * @Title: JsonResult
	 * @Description: 成功信息返回
	 * @param: @param status
	 * @param: @param data
	 * @throws
	 */
	public JsonResult(String status, Object data) {
		super();
		this.status = status;
		this.data = data;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getResultCode() {
		return resultCode;
	}

	public void setResultCode(String resultCode) {
		this.resultCode = resultCode;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}
	
	public boolean isAllowchange() {
		return allowchange;
	}

	public void setAllowchange(boolean allowchange) {
		this.allowchange = allowchange;
	}

	/**
	 * Description:转换为json格式
	 * 
	 * @return
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return JSON.toJSONString(this);
	}

	public Object getExtradata() {
		return extradata;
	}

	public void setExtradata(Object extradata) {
		this.extradata = extradata;
	}

}
